<#include file="public/header.html"#>

<div class="wrap">
    <div class="top-icon add-icon f16">
        <div class="icon"><br /></div>
        添加内容
        <br class="clear" />
    </div>

    <div class="add-form">
        <form action="<#url class=Content function=edit ac=saveEditNode nid=$T.get.nid#>" method="post" name="addnew">
            <div id="titlewrap">
                <#if $node.title == ''#>
                <label for="title" id="title-prompt-text" style="" class="title-prompt">在此键入标题</label>
                <#/if#>
                <input type="text" id="title" value="<#$node.title#>" tabindex="1" size="30" name="post_title" class="title" onfocus="javascript:document.getElementById('title-prompt-text').style.display='none';" />
            </div>
            <div id="contentwrap">
                <script type="text/javascript" src="/Public/js/kind/kindeditor-min.js"></script>
                <textarea name="post_content" cols="50" rows="8" id="post_content" style="visibility:hidden;"><#$node.content#></textarea>
                <script>
                    KE.show({
                        id : 'post_content',
                        resizeMode : 1,
                        allowPreviewEmoticons : false,
                        allowUpload : false,
                        width:"85%",
                        height:"300px",
                        items : [
                            'source','fontname', 'fontsize',  'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
                            'removeformat',  'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                            'insertunorderedlist', 'advtable', 'emoticons', 'image', 'link']
                    });
                </script>
            </div>
            <div id="addform-upload" class="mt10">
                <fieldset>
                    <legend>插入/上传</legend>
                    <iframe align="left" width="100%" scrolling="no" frameborder="0" height="30" src="<#url class=Attach function=upload multi=true#>"></iframe>
                </fieldset>
            </div>

            <div id="addform-cate" class="mt10">
                <fieldset>
                    <legend>内容分类</legend>
                    <table border="0"  border="0" cellpadding="0" class="wp60" cellspacing="1">
                        <tr>
                            <td width="20%">
                                <select name="category" id="category">
                                    <#$cateOptions#>
                                </select>
                            </td>
                            <td width="70%">
                                添加新类 &gt; 
                                <input type="text" class="wp30" name="newCateName" id="newCateName" />
                                请选择父类 &gt; 
                                <select name="parentCate" id="parentCate">
                                    <#$cateOptions#>
                                </select>
                                <input type="button" class="button" value="添加" id="submitNewCate" />
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </div>
            <div id="addform-publish" class="mt10">
                <fieldset>
                    <legend>发布</legend>
                    是否发布
                    <input type="checkbox" name="status" <#if $node.status#>checked<#/if#> value="1" />
                    是否推荐
                    <input type="checkbox" name="commend" <#if $node.commend#>checked<#/if#> value="1" />
                    权重
                    <select name="weight">
                        <#for $i=-127 to 127#>
                        <option <#if $node.weight == $i#>selected<#/if#> value="<#$i#>"><#$i#></option>
                        <#/for#>
                    </select>                    
                </fieldset>
            </div>


            <DIV ID="buttionwrap" class="mt10">
                <input type="submit" class="button submit" value="保 存" />
                <input type="button" id="btn-back" class="button" value="返 回" />
            </DIV>

        </form>
        <script>
            (function($){
                $("#btn-back").click(function(){
                    window.history.back();
                });
                $("#submitNewCate").click(function(){
                    var newCateName=$("#newCateName").val();
                    var parentCate=$("#parentCate").val();
                    if(newCateName==''){
                        alert("新类名不能为空");
                        return false;
                    }
                    $.ajax({
                        url:"<#url class=Attach function=saveNewCate ac=savenewcategory#>",
                        type:"POST",
                        data:{name:newCateName,pid:parentCate},
                        success:function(data){
                            eval("data="+data);
                            if(data.saved){$("#category").prepend("<option value='"+data.cid+"' selected>"+newCateName+"</option>");}
                        }
                    });
                });
            })(jQuery)
        </script>
    </div>
</div>

<#include file="public/footer.html"#>